package com.bw.zh32301

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.lifecycleScope
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.bw.base.mvvm.BaseViewActivity
import com.bw.zh32301.databinding.ActivityMainBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@AndroidEntryPoint
class MainActivity : BaseViewActivity<ActivityMainBinding>() {
    override fun initView() {
        val s = SPUtils.getInstance().getString("img")
        if (s=="1"){
            ARouter.getInstance().build("/app/MainActivity2").navigation()
            finish()
        }
        binding.tv2.setOnClickListener {
            ARouter.getInstance().build("/app/MainActivity2").navigation()
            finish()
        }
        lifecycleScope.launch {
            for (i in 5 downTo 1){
                binding.tv.text = "$i S"
                delay(1000)
                if (i==1){
                    ARouter.getInstance().build("/app/MainActivity2").navigation()
                    SPUtils.getInstance().put("img","1")
                    finish()
                }
            }
        }
    }

    override fun initData() {

    }
}